-- ============================================
-- TEST MANETTE - diagnostic Redstone Integrator
-- Affiche en direct quelle face s'active quand tu appuies sur
-- un bouton de la telecommande Create. Sert a identifier le
-- mapping exact pour remplir la table BUTTONS de rocket_runner.
-- ============================================

local integrator = peripheral.find("redstoneIntegrator")
if not integrator then
    error("Aucun Redstone Integrator trouve ! Colle-en un (Advanced Peripherals) relie au computer.")
end

local SIDES = { "top", "bottom", "left", "right", "front", "back" }

local function readAll()
    local state = {}
    for _, side in ipairs(SIDES) do
        state[side] = integrator.getInput(side)
    end
    return state
end

term.clear()
term.setCursorPos(1, 1)
print("=== TEST MANETTE ===")
print("Appuie sur chaque bouton de la telecommande un par un.")
print("La face qui s'allume s'affiche ci-dessous.")
print("Ctrl+T pour arreter.")
print("")

local prev = readAll()

while true do
    sleep(0.05)
    local current = readAll()
    for _, side in ipairs(SIDES) do
        if current[side] and not prev[side] then
            print("Face activee : " .. side)
        end
    end
    prev = current
end